package indi.kider.server.applet.service;

import indi.kider.common.model.apabus.Rent;
import indi.kider.common.model.apartment.Houses;
import indi.kider.common.model.employee.Tenant;
import indi.kider.server.apartment.mapper.HousesMapper;
import indi.kider.server.applet.model.TenantVo;
import indi.kider.server.employee.mapper.TenantMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
@Service
public class TempFilterServiceImpl implements TempFilterService {

    @Autowired
    private TenantMapper tenantMapper;
    @Autowired
    private HousesMapper housesMapper;

    @Override
    public TenantVo verifyTenant(Long tenantId) {
        Tenant   tenant   = tenantMapper.selectByPrimaryKey(tenantId);
        TenantVo tenantVo = new TenantVo();
        tenantVo.setName(tenant.getName());
        tenantVo.setCompyName(tenant.getFormCompy());

        try {
            Rent   rent   = tenantMapper.getTanantRent(tenant);
            Houses houses = housesMapper.selectByPrimaryKey(rent.getHousesId());
            tenantVo.setCanPayOnline((houses.getPayOnline() > 1));
        } catch (Exception e) {

        }

        return tenantVo;
    }
}
